<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <title>文档</title>
  <link href="../css/semantic/semantic.min.css" rel="stylesheet">
  <link href="../css/markdown.css" rel="stylesheet">
    <link href="../css/wtxynavigation.css" rel="stylesheet">
    <script src="../js/jquery.min.js"></script>
    <script type="text/javascript" src="../js/include.js"></script>
  <style>
    body{padding-top:0;background:#f7f7f7}
    body>.ui.container{width:100%;padding:0}
    #project-title{background:#6e6e6e;width:100%;line-height:3.572rem;color:#fff;font-size:1.2rem}
    #project-title .title-wrap{font-weight:700;padding:0 12px;width:100%;max-width:1366px!important;min-width:900px;margin:0 auto}
    #project-title .left,#project-title right{display:inline-block}
    #project-title .right{float:right}
    #project-title .right .wiki-actions .menu{left:auto;right:0;margin-top:.4em!important}
    #wiki-preview-container{width:100%;max-width:1366px!important;min-width:900px;padding:0;border:1px solid #e3e9ed;border-top:0}
    #wiki-preview>.ui.segment{margin-top:0;padding:1rem;padding-left:0;border:0}
    .hover-places{display:inline-block}
    #page-detail{width:60%;margin:0 auto}
    #page-detail .title{font-weight:700;font-size:24px;padding:12px 0;border-bottom:1px solid #ccc}
    #page-detail .content{margin-top:15px}
    .content p{word-wrap:break-word}
    #wiki-parent,#wiki-title,#wikis{display:none}
    .ui.grid{padding:0!important}
    #ex-all{cursor:pointer;color:#537c8d}
  </style>
</head>
<body>
  <div class="ui container">

      <div id="wtxyNav"></div>

    <div class="ui container" id="wiki-preview-container">
      <div id="wiki-preview">
        <div class="ui segment">
          <div id="page-detail" class="markdown-body">
            <div class='title'>11.GCD同步串行问题</div><div class='content'><h1>
<a id="gcd同步串行问题" class="anchor" href="#gcd%E5%90%8C%E6%AD%A5%E4%B8%B2%E8%A1%8C%E9%97%AE%E9%A2%98"></a>GCD同步串行问题</h1>
<h1>
<a id="如下代码是否有问题" class="anchor" href="#%E5%A6%82%E4%B8%8B%E4%BB%A3%E7%A0%81%E6%98%AF%E5%90%A6%E6%9C%89%E9%97%AE%E9%A2%98"></a>如下代码是否有问题</h1>
<pre><code>
- (void)viewDidLoad {
    [super viewDidLoad];
    
    dispatch_sync(dispatch_get_main_queue(), ^{
        
        [self doSomething];
    });
}

</code></pre>
<h2>
<a id="描述" class="anchor" href="#%E6%8F%8F%E8%BF%B0"></a>描述</h2>
<ol>
<li>队列的性质: <strong>队列先进先出</strong>
</li>
<li>主队了中,不管是通过同步方式还是通过异步方式都会在主线程中执行</li>
</ol>
<h3>
<a id="1" class="anchor" href="#1"></a>1.</h3>
<h1>
<a id="答" class="anchor" href="#%E7%AD%94"></a>答:</h1>
<h2>
<a id="1-如上代码会产生死锁" class="anchor" href="#1-%E5%A6%82%E4%B8%8A%E4%BB%A3%E7%A0%81%E4%BC%9A%E4%BA%A7%E7%94%9F%E6%AD%BB%E9%94%81"></a>1. 如上代码会产生死锁</h2>
<h2>
<a id="2-死锁原因-队列引起的循环等待-不是线程引起的" class="anchor" href="#2-%E6%AD%BB%E9%94%81%E5%8E%9F%E5%9B%A0-%E9%98%9F%E5%88%97%E5%BC%95%E8%B5%B7%E7%9A%84%E5%BE%AA%E7%8E%AF%E7%AD%89%E5%BE%85-%E4%B8%8D%E6%98%AF%E7%BA%BF%E7%A8%8B%E5%BC%95%E8%B5%B7%E7%9A%84"></a>2. 死锁原因: 队列引起的循环等待, 不是线程引起的</h2>
<p><strong>详解见视频</strong></p></div>
          </div>
        </div>
      </div>
      </div>
  </div>
</body>
</html>